package com.robot.member.dao;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;

import com.robot.member.pojo.MerchantApply;

import java.util.List;

/**
 * 商户入驻申请merchant_apply数据访问接口
 *
 * @author wuyunbin
 */
public interface MerchantApplyDao extends JpaRepository<MerchantApply, String>, JpaSpecificationExecutor<MerchantApply> {
    /**
     * 通过storeId查询最新merchant_apply详情
     *
     * @param storeId
     * @return
     */
    MerchantApply findTopByStoreIdOrderByUpdatedAtDesc(String storeId);

    /**
     * 通过memberId和deletedAt查询merchant_apply列表
     *
     * @param memberId
     * @param pageable
     * @return
     */
    Page<MerchantApply> findAllByMemberIdAndDeletedAtIsNullOrderByUpdatedAtDesc(String memberId, Pageable pageable);

    /**
     * 通过areaId查询merchant_apply列表
     *
     * @param areaId
     * @return
     */
    public List<MerchantApply> findAllByAreaIdAndDeletedAtIsNullOrderByUpdatedAtDesc(String areaId);

    /**
     * 通过areaId和status查询merchant_apply列表
     *
     * @param areaId
     * @param status
     * @return
     */
    public List<MerchantApply> findAllByAreaIdAndStatusAndDeletedAtIsNullOrderByUpdatedAtDesc(String areaId, String status);

    /**
     * 通过id和memberId查询merchant_apply详情
     *
     * @param id
     * @param memberId
     * @return
     */
    MerchantApply findByIdAndMemberIdAndDeletedAtIsNull(String id, String memberId);

    /**
     * 通过phone查询merchant_apply列表
     *
     * @param phone
     * @return
     */
    List<MerchantApply> findAllByPhone(String phone);

    /**
     * 通过id和status查询merchant_apply
     *
     * @param id
     * @param memberId
     * @param status
     * @return
     */
    MerchantApply findByIdAndMemberIdAndStatusAndDeletedAtIsNull(String id, String memberId, String status);

}
